package com.hundsun.yr.universal.p2p.bean;

import android.content.Context;
import android.text.TextUtils;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.library.utils.HsNumberUtils;

import java.io.Serializable;

/**
 * Created by xx on 2017/5/10.
 */
public class MyInvestBeen implements Serializable{
    /**
     * amount : 2000.00
     * ctime : 1493718366
     * discount_amt : 0.00
     * end_time : 2018-05-02
     * name : 车分融提前还款
     * orderprogress : 20
     * pay_method : 4
     * progress : 20
     * rate : 8.5000
     * serial_no : 20170502174606c44fa6e56df47f34
     * start_time : 2017-05-02
     * total_term : 12
     * true_amount : 2000.00
     * user_no : 20170309101643874893
     * uuid : 00026b
     * accu_income :
     * repayed_term : 3
     * total_income :
     * next_repay_day : 2017-05-08
     */

    public String amount;
    public String ctime;
    public String discount_amt;
    public String end_time;
    public String name;
    public String orderprogress;
    public String pay_method;
    public String progress;
    public String rate;
    public String serial_no;
    public String start_time;
    public String total_term;
    public String true_amount;
    public String user_no;
    public String uuid;
    public String accu_income;
    public String repayed_term;
    public String total_income;
    public String next_repay_day;
    /**
     * retotal_term : 1
     */

    public String retotal_term;
    /**
     * repay_time : 2017-06-14 18:17:21
     */

    public String repay_time;

    /**
     * 0	未发布
     10	投标中
     15	待放款
     18	放款中
     20	计息中
     30	待返还（暂时不用）
     40	已返还
     50	已结束
     60	已撤销
     100	逾期未返还
     105	逾期部分返还（暂不开发）
     110	逾期已返还
     120	流标
     125	停售（募集期截止但未募满）
     130	风控拒绝放款
     200	逾期已返还(与11重复废弃)
     * @return
     */
    public String getProgress(Context mContext){
        if (TextUtils.equals(progress,"0")){
            return mContext.getString(R.string.progress0);
        } else if (TextUtils.equals(progress,"10")){
            return mContext.getString(R.string.progress10);
        } else if (TextUtils.equals(progress,"15")){
            return mContext.getString(R.string.progress15);
        } else if (TextUtils.equals(progress,"18")){
            return mContext.getString(R.string.progress18);
        } else if (TextUtils.equals(progress,"20")){
            return mContext.getString(R.string.progress20);
        } else if (TextUtils.equals(progress,"30")){
            return mContext.getString(R.string.progress30);
        } else if (TextUtils.equals(progress,"40")){
            return mContext.getString(R.string.progress40);
        } else if (TextUtils.equals(progress,"50")){
            return mContext.getString(R.string.progress50);
        } else if (TextUtils.equals(progress,"60")){
            return mContext.getString(R.string.progress60);
        } else if (TextUtils.equals(progress,"100")){
            return mContext.getString(R.string.progress100);
        } else if (TextUtils.equals(progress,"105")){
            return mContext.getString(R.string.progress105);
        } else if (TextUtils.equals(progress,"110")){
            return mContext.getString(R.string.progress110);
        }else if (TextUtils.equals(progress,"120")){
            return mContext.getString(R.string.progress120);
        } else if (TextUtils.equals(progress,"125")){
            return mContext.getString(R.string.progress125);
        } else if (TextUtils.equals(progress,"130")){
            return mContext.getString(R.string.progress130);
        } else if (TextUtils.equals(progress,"200")){
            return mContext.getString(R.string.progress200);
        } else {
            return "other";
        }
    }

    public String getOrderProgress(){
        if (TextUtils.equals(orderprogress,"10")){
            return "处理中";
        } else if (TextUtils.equals(orderprogress,"15")){
            return "银行处理中";
        } else if (TextUtils.equals(orderprogress,"20")){
            return "已付款";
        } else if (TextUtils.equals(orderprogress,"30")){
            return "计息中";
        } else if (TextUtils.equals(orderprogress,"50")){
            return "已兑付";
        } else if (TextUtils.equals(orderprogress,"100")){
            return "已撤销";
        } else {
            return "超时关闭";
        }
    }

    /**
     * 显示投资期限
     * @return
     */
    public String getTerm(){
        String duration= HsNumberUtils.numberFormat("##0", total_term)+getPayMethod(pay_method);
        return duration;
    }

    public static String getPayMethod(String pay_method) {

        String limttype = "";

        switch (pay_method){
            case "1":
                limttype = "天";
                break;
            default :
                limttype = "月";
                break;
        }
        return limttype;
    }

    public String getPayMethod(Context mContext) {
        String payMethod = "";
        switch (pay_method) {
            case "1":
                payMethod = mContext.getString(R.string.debt_service_at_maturity);
                break;
            case "2":
                payMethod = mContext.getString(R.string.first_coupon_later_edition);
                break;
            case "3":
                payMethod = mContext.getString(R.string.monthly_equal_principal_and_interest);
                break;
            case "4":
                payMethod = mContext.getString(R.string.monthly_principal);
                break;
        }
        return payMethod;
    }

    @Override
    public String toString() {
        return "MyInvestBeen{" +
                "amount='" + amount + '\'' +
                ", ctime='" + ctime + '\'' +
                ", discount_amt='" + discount_amt + '\'' +
                ", end_time='" + end_time + '\'' +
                ", name='" + name + '\'' +
                ", orderprogress='" + orderprogress + '\'' +
                ", pay_method='" + pay_method + '\'' +
                ", progress='" + progress + '\'' +
                ", rate='" + rate + '\'' +
                ", serial_no='" + serial_no + '\'' +
                ", start_time='" + start_time + '\'' +
                ", total_term='" + total_term + '\'' +
                ", true_amount='" + true_amount + '\'' +
                ", user_no='" + user_no + '\'' +
                ", uuid='" + uuid + '\'' +
                ", accu_income='" + accu_income + '\'' +
                ", repayed_term='" + repayed_term + '\'' +
                ", total_income='" + total_income + '\'' +
                ", next_repay_day='" + next_repay_day + '\'' +
                ", retotal_term='" + retotal_term + '\'' +
                ", repay_time='" + repay_time + '\'' +
                '}';
    }
}
